package com.main.UIOptions;

import com.gryffonx.Interfaces.generators.NameGeneratorsBinding;
import com.gryffonx.utils.StringUtils;

import javax.swing.*;

/**
 * @author Erik Stell
 * @version 1.0
 */
public class NameGeneratorMenuBar {

    /**
     * @param pnl
     * @return
     */
    public static JMenuBar getMenu(NameGeneratorsBinding pnl) {

        ImageIcon deleteOrExitIcon = StringUtils.createImageIcon("/images/deleteOrExit.gif");
        ImageIcon openIcon = StringUtils.createImageIcon("/images/open.gif");
        ImageIcon printIcon = StringUtils.createImageIcon("/images/print.gif");
        ImageIcon saveIcon = StringUtils.createImageIcon("/images/save.gif");

        ImageIcon cutIcon = StringUtils.createImageIcon("/images/cut.gif");
        ImageIcon copyIcon = StringUtils.createImageIcon("/images/copy.gif");
        ImageIcon pasteIcon = StringUtils.createImageIcon("/images/paste.gif");
        ImageIcon undoIcon = StringUtils.createImageIcon("/images/undo.gif");
        ImageIcon redoIcon = StringUtils.createImageIcon("/images/redo.gif");
        ImageIcon searchIcon = StringUtils.createImageIcon("/images/search.gif");

        ImageIcon aboutIcon = StringUtils.createImageIcon("/images/aboutApp.gif");
        ImageIcon searchHelpIcon = StringUtils.createImageIcon("/images/searchHelp.gif");
        ImageIcon helpContentsIcon = StringUtils.createImageIcon("/images/helpContents.gif");
        ImageIcon helpIndexIcon = StringUtils.createImageIcon("/images/helpIndex.gif");

        JMenuBar menu = new JMenuBar();
        JMenu mnuFile = new JMenu("File");

        //open file params
        JMenuItem mntmFileOpen = new JMenuItem("Open Saved File", openIcon);
        mntmFileOpen.setMnemonic(1);
        mntmFileOpen.addActionListener(UIActionListeners.openAction(pnl));
        mnuFile.add(mntmFileOpen);

        //save file params
        JMenuItem mntmFileSave = new JMenuItem("Save Generated Results", saveIcon);
        mntmFileSave.setMnemonic('s');
        mntmFileSave.addActionListener(UIActionListeners.saveAction(pnl));
        mnuFile.add(mntmFileSave);

        //print file params
        JMenuItem mntmPrint = new JMenuItem("Print Saved List", printIcon);
        mntmPrint.setMnemonic('p');
        mntmPrint.addActionListener(UIActionListeners.printAction(pnl));
        mnuFile.add(mntmPrint);

        mnuFile.add(new JSeparator());

        //close application window params
        JMenuItem mntmFileClose = new JMenuItem("Exit Name Generator", deleteOrExitIcon);
        mnuFile.add(mntmFileClose);

        JMenu mnuEdit = new JMenu("Edit");
        JMenuItem mntmEditCut = new JMenuItem("Cut", cutIcon);
        JMenuItem mntmEditCopy = new JMenuItem("Copy", copyIcon);
        JMenuItem mntmEditPaste = new JMenuItem("Paste", pasteIcon);
        JMenuItem mntmEditUndo = new JMenuItem("Undo", undoIcon);
        JMenuItem mntmEditRedo = new JMenuItem("Redo", redoIcon);
        JMenuItem mntmEditSearch = new JMenuItem("Search", searchIcon);
        mnuEdit.add(mntmEditCut);
        mnuEdit.add(mntmEditCopy);
        mnuEdit.add(mntmEditPaste);
        mnuEdit.add(new JSeparator());
        mnuEdit.add(mntmEditUndo);
        mnuEdit.add(mntmEditRedo);
        mnuEdit.add(new JSeparator());
        mnuEdit.add(mntmEditSearch);
        JMenu mnuHelp = new JMenu("Help");
        JMenuItem mntmHelpAbout = new JMenuItem("About Name Generator", aboutIcon);
        mntmHelpAbout.addActionListener(UIActionListeners.aboutAction(pnl));
        JMenuItem mntmHelpContents = new JMenuItem("Help Contents", helpContentsIcon);
        JMenuItem mntmHelpIndex = new JMenuItem("Help Index", helpIndexIcon);
        JMenuItem mntmHelpSearch = new JMenuItem("Search Help Contents", searchHelpIcon);
        mnuHelp.add(mntmHelpContents);
        mnuHelp.add(mntmHelpIndex);
        mnuHelp.add(mntmHelpSearch);
        mnuHelp.add(new JSeparator());
        mnuHelp.add(mntmHelpAbout);

        menu.add(mnuFile);
        menu.add(mnuEdit);
        menu.add(mnuHelp);

        return menu;
    }
}